import { ElMessage } from "element-plus";

//自定义Confirm
export const CustomerConfirm = (
  message,
  title,
  okBtn = `Ok`,
  cancelBtn = `Cancel`,
  btnType = `warning`,
  confirmFn,
  cancelFn
) => {
  ElMessageBox.confirm(message, title, {
    confirmButtonText: okBtn,
    cancelButtonText: cancelBtn,
    type: btnType,
  })
    .then(() => {
      if (confirmFn && typeof confirmFn === "function") {
        console.log("点击了确认方法");
        confirmFn();
      }
    })
    .catch(() => {
      if (cancelFn && typeof cancelFn === "function") {
        console.log("点击了取消方法");
        cancelFn();
      }
    });
};

//自定义Message
export const CustomerMessage = (
  message,
  type,
  showClose = true,
  center = false,
  duration = 3000
) => {
  ElMessage({
    message: message,
    type: type,
    showClose: showClose,
    center: center,
    duration: duration,
  });
};
